<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Users</title>
</head>
<body>
    <h1>Users</h1>
    <table>
        <thead>
            <tr>
                <th>Last Name</th>
                <th>First Name</th>
                <th>Email</th>
                <th>Role</th>
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>
            {% for user in users %}
            <tr>
                <td>{{ user.last_name }}</td>
                <td>{{ user.first_name }}</td>
                <td>{{ user.email }}</td>
                <td>{{ user.role.name if user.role else 'No Role' }}</td>
                <td>
                    <form action="/assign_role" method="post" style="display:inline;">
                        <select name="role">
                            {% for role in roles %}
                            <option value="{{ role.name }}">{{ role.name }}</option>
                            {% endfor %}
                        </select>
                        <input type="hidden" name="user_id" value="{{ user.id }}">
                        <button type="submit">Assign Role</button>
                    </form>
                    <form action="/remove_role" method="post" style="display:inline;">
                        <input type="hidden" name="user_id" value="{{ user.id }}">
                        <button type="submit">Remove Role</button>
                    </form>
                    <form action="/delete_user/{{ user.id }}" method="post" style="display:inline;">
                        <button type="submit">Delete</button>
                    </form>
                    <form action="/edit_user/{{ user.id }}" method="get" style="display:inline;">
                        <button type="submit">Edit</button>
                    </form>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</body>
</html>
